<?php
	// Affichage des erreurs s'il y en a
	if(isset($errors) && 0 != count($errors))
		foreach($errors as $error)
			echo "<p class='error'>".$error."</p>";
?>

<form action="#" method="post" enctype="multipart/form-data">
	<table>
		<tr>
			<td>Titre:</td>
			<td><input type="text" name="titre" value="<?php echo $titre; ?>"/></td>
		</tr>
		<tr>
			<td>R&eacute;sum&eacute;:</td>
			<td><textarea id="resume" name="resume"><?php echo $resume; ?></textarea></td>
		</tr>
		<tr>
			<td>Contenu:</td>
			<td><textarea name="contenu"><?php echo $contenu; ?></textarea></td>
		</tr>
		<tr>
			<td>Image:<?php if(null != $image) echo "<img src='images/". $image."'/>";?></td>
			<td><input type="file" name="image" id="image"/></td>
		</tr>
		<tr>
			<td>Cat&eacute;gorie:</td>
			<td>
				<select name="categorie">
				<?php
					foreach($mainCategoriesList as $mainCat)
					{
						$tabCat[$mainCat->getIdCat()]= $mainCat->getNameCat();
						
	
						echo "<option value='".$mainCat->getIdCat()."'>".$mainCat->getNameCat()."</option>";
						
						$subcategoriesList = Category::listing("WHERE CAT_IdParent = ".$mainCat->getIdCat());
						
						foreach($subcategoriesList as $subCat)
						{
							$tabCat[$subCat->getIdCat()]= $subCat->getNameCat();
							if($idCat==$subCat->getIdCat())
								echo "<option value='".$subCat->getIdCat()."' selected='selected'>----".$subCat->getNameCat()."</option>";
							else
								echo "<option value='".$subCat->getIdCat()."'>----".$subCat->getNameCat()."</option>";
						}
					}
				?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Statut:</td>
			<td>
				<select name="statut">
				<?php
				
					foreach($statusList as $status)
					{
						$tabStatus[$status->getIdStatus()]= $status->getNameStatus();
						if($idStatus==$status->getIdStatus())
							echo "<option value='".$status->getIdStatus()."' selected='selected'>".$status->getNameStatus()."</option>";
						else
							echo "<option value='".$status->getIdStatus()."' >".$status->getNameStatus()."</option>";
					}

					?>
				
				</select>
			</td>
		</tr>
		<tr>
			<td><input type="submit" value="<?php echo $bouton=(isset($_GET['action']) && "edit"==$_GET['action'])?"Editer":"Cr&eacute;er"; ?> "/></td>
		</tr>
		<input type='hidden' name='idEdit' value='<?php echo $id=(isset($_GET['action']) && "edit"==$_GET['action'])?$_GET['idArt']:null; ?>'/>
	</table>	
</form>




<hr>